package com.xidian.zhiancloud.controller.accidentManage;

import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.qo.accidentmessage.AccidentStatisticQO;
import com.xidian.zhiancloud.service.accidentManage.AccidentStatisticService;
import com.xidian.zhiancloud.vo.accidentmessage.AccidentStatisticVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName StatisticController
 * @Description 事故信息统计图表接口
 * @Author Halo
 **/
@RestController
@RequestMapping("/accidentStatistic")
public class AccidentStatisticController extends BaseController {

    @Resource
    private AccidentStatisticService accidentStatisticService;

    /**
     * 根据事故类型进行统计
     * @param accidentStatisticQO 查询请求参数
     * @return 返回查询结果、List<AccidentStatisticVO>类型
     */
    @GetMapping("/statisticByType")
    public ResultDTO<List<AccidentStatisticVO>> statisticByType(AccidentStatisticQO accidentStatisticQO){
        accidentStatisticQO.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(accidentStatisticService.statisticByType(accidentStatisticQO),
                GeneralResponseEnums.SUCCESS);
    }

    /**
     * 根据事故等级进行统计
     * @param accidentStatisticQO 查询的请求参数
     * @return 返回查询结果、List<AccidentStatisticVO>类型
     */
    @GetMapping("/statisticByRank")
    public ResultDTO<List<AccidentStatisticVO>> statisticByRank(AccidentStatisticQO accidentStatisticQO){
        accidentStatisticQO.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(accidentStatisticService.statisticByRank(accidentStatisticQO),
                GeneralResponseEnums.SUCCESS);
    }

    /**
     * 根据责任部门进行统计
     * @param accidentStatisticQO 查询的请求参数
     * @return 返回查询结果、List<AccidentStatisticVO>类型
     */
    @GetMapping("/statisticByDepartment")
    public ResultDTO<List<AccidentStatisticVO>> statisticByDepartment(AccidentStatisticQO accidentStatisticQO){
        accidentStatisticQO.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(accidentStatisticService.statisticByDepartment(accidentStatisticQO),
                GeneralResponseEnums.SUCCESS);
    }
}
